package DMSXL._2024.TX;

import java.util.Arrays;
import java.util.LinkedList;

public class reconstructQueue {
    public static void main(String[] args){

    }
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people,(a,b) ->{
            if(a[0] == b[0]){
                return a[1] - b[1];
            }
            return b[0] - a[0];
        });

        LinkedList<int[]> queqe = new LinkedList<>();
        for (int[] p : people) {
            queqe.add(p[1],p);
        }
        return queqe.toArray(new int[people.length][]);
    }
}
